/**
 * 
 */
package com.google.code.cisx.client.event;

import java.util.EventObject;

/**
 * Represents a typed event. Motivation behind this is that related events can
 * belong to a <b>class</b> of events.
 * <p>
 * For instance, we can <em>classify</em> the following <em>types</em> of
 * Login events.
 * <ul>
 * <li>User login/Session started</li>
 * <li>User logout/Session terminated</li>
 * <li>Session timeout/User logout</li>
 * </ul>
 * 
 * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
 * @since 1.0
 * @version $Id: TypedEvent.java 258 2008-11-29 06:23:51Z rahul.thakur.xdev $
 */
public abstract class TypedEvent extends EventObject {

  /**
   * The type of event.
   */
  private String type;

  /**
   * @param source
   */
  public TypedEvent(Object source) {
    super(source);
  }

  /**
   * @param source
   * @param type
   */
  public TypedEvent(Object source, String type) {
    super(source);
    this.type = type;
  }

  /**
   * @return the type
   */
  public String getType() {
    return type;
  }

  /**
   * Returns a {@link String} representation for this Event instance.
   */
  @Override
  public String toString() {
    return "Event: " + this.getClass().getName() + ", Type: " + getType() + ", Source: "
        + getSource().getClass().getName();
  }

}
